<?php

namespace App\Http\Controllers\Api;

use App\Coupon;
use App\Exports\CommissionExport;
use App\Exports\OrderExport;
use App\Exports\PrintExport;
use App\GroupBuyItem;
use App\GroupMaster;
use App\Http\Controllers\Controller;
use App\Jobs\ReceivingJob;
use App\Merchant;
use App\Order;
use App\OrderDetail;
use App\Services\ExpressService;
use App\Services\PayService;
use App\Services\WechatService;
use App\Sku;
use App\User;
use App\UserCoupon;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Intervention\Image\Facades\Image;
use Maatwebsite\Excel\Facades\Excel;

class TestController extends Controller
{
    public $uid=1;
    public function index()
    {
//      $order=Order::all();
//      foreach ($order as $key=>$value){
//          if ($value['share_uid']==5){
//              $value['share_uid']=220;
//          }
//          User::where('id',$value['uid'])->update(['parent_id'=>$value['share_uid']]);
//        $order=Order::find(79);
//        $payService=new PayService();
//        $payService->success($order['order_number'],[]);
//      }

//        foreach ($order as $key=>$v){
//            $coupon=Coupon::find(1);
//            $user_coupon=[
//                'uid'=>$v['uid'],
//                "coupon_id"=>$coupon->id,
//                "price"=>$coupon->price,
//                "fill_money"=>$coupon->fill_money,
//                "exp_time"=>Carbon::now()->addDays($coupon->exp_day),
//                "status"=>0,
//                "bind_goods"=>[],
//                "title"=>$coupon->title
//            ];
//            UserCoupon::create($user_coupon);
//        }
        $app=app('wechat.mini_program');
        $response = $app->app_code->get('pages/product/product?id=9', [
            'width' => 600,
            'line_color' => [
                'r' => 0,
                'g' => 0,
                'b' => 0,
            ],
            'is_hyaline'=>true
        ]);
//
//// $response 成功时为 EasyWeChat\Kernel\Http\StreamResponse 实例，失败时为数组或者你指定的 API 返回格式
//
//
//
//        $service=new WechatService();
//        $response = $service->get("pages/pro")
//// 或
        if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
            $filename = $response->saveAs(public_path("images/qrcode"), 'goods.png');
        }
//        $data=[1,2,3,4,5,6,7,8,9,10,11,12,13];
//        $orders=Order::whereIn('id',$data)->get();
//        $orders=$orders->groupBy('address_phone_number');
//        $data=[
//            "order_id"=>"2020091620141428765",
//            "waybill_id"=>"SF6026114184593",
//            "delivery_id"=>"SF"
//        ];
////        dd($orders);
//        $result=$app->express->deleteWaybill($data);
//        dd($result);
//      return Excel::download(new PrintExport("2020-09-16 00:00:00","2020-09-17 00:00:00"),'print.xlsx');

    }
}
